<%-- 
    Document   : partydb
    Created on : Jan 14, 2013, 9:08:11 AM
    Author     : Bittuji
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page import="java.io.*,java.sql.*" %>
<%@include file="db.jsp" %>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body>
        <%
        
        
        String prid = request.getParameter("prid");
        String[] prtype =request.getParameterValues("prtype");
        String prname = request.getParameter("prname");
        String prtno = request.getParameter("prtno");
        String pradd = request.getParameter("pradd");
        int cpn = Integer.parseInt(request.getParameter("cpn"));
        int pcn = Integer.parseInt(request.getParameter("pcn"));
        
        for(int i=0;i<prtype.length;i++)
        {
        String sql = "INSERT INTO `party_master`(`party_id`, `party_type`, `party_name`, `party_tin_no`, `party_address`, `contact_p_no`, `party_c_p_no`) VALUES (?,?,?,?,?,?,?)" ;
        PreparedStatement pstmt = con.prepareStatement(sql);
        
        pstmt.setString(1, prid);
        pstmt.setString(2, prtype[i]);
        pstmt.setString(3, prname);
        pstmt.setString(4, prtno);
        pstmt.setString(5, pradd);
        pstmt.setInt(6, cpn);
        pstmt.setInt(7, pcn);
        
        int result = pstmt.executeUpdate();
        
        
        if(result==1)
        System.out.println("DATA INSERTED");
        response.sendRedirect("party.jsp");
        }
        
        %>
        
        
        
    </body>
</html>
